package com.mms.dao;

import org.apache.ibatis.jdbc.Null;

import com.mms.entity.CustomerState;

public class DynamicSQL {
	
	public static void main(String[] args) {
		// 三个查询条件参数
		String nameOrPhone = null;
		CustomerState state = CustomerState.INTENTIONAL;
		String ownerUsername = null;
		
		String sql = "select * from customer where 1=1";
		
		if (nameOrPhone != null) { // 这说明用户输入了有效的姓名电话关键字
			sql += " and (name like ? or phone like ?)";
		}
		if (state != null) {
			sql += " and state = ?";
		}
		if (ownerUsername != null) {
			sql += " and owner_username = ?";
		}
		
		System.out.println(sql);
	}

}
